package com.crecheng.shop.util;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public final class Util {
    public static List<Field> getAllFields(Class<?> Class){
        ArrayList<Field> list=new ArrayList<>();
        getAllFields(Class,list);
        return list;
    }

    static void getAllFields(Class<?> Class,List<Field> list){
        list.addAll(Arrays.asList(Class.getDeclaredFields()));
        var superClass=Class.getSuperclass();
        if(superClass!=Object.class)
            getAllFields(superClass,list);
    }
}
